package com.itheima.mapper;

import com.itheima.entity.ArticleHot;
import com.itheima.entity.YddArticle;
import com.itheima.vo.YddArticleRecommend;
import com.itheima.vo.YddArticleShowPart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface YddArticleMapper {

    /**
     * pag
     *
     * @param title      标题
     * @param cateid     cateid
     * @param start_time 开始时间
     * @param end_time   结束时间
     * @return {@link List}<{@link YddArticle}>
     */
    List<YddArticle> pag(String title, Integer cateid, Long startTime, Long endTime);

    /**
     * 选择cate名称
     *
     * @param cateid cateid
     * @return {@link String}
     */
    String selectCateName(Integer cateid);

    /**
     * 创建文章
     *
     * @return {@link YddArticle}
     */
    void creatArticle(YddArticle yddArticle);

    /**
     * 查询文章
     *
     * @param id id
     * @return {@link YddArticle}
     */
    YddArticle queryArticle(Integer id);

    /**
     * 删除文章
     *
     * @param id id
     */
    void deleteArticle(Integer id);

    /**
     * 更新文章
     *
     * @param yddArticle ydd文章
     */
    void updateArticle(YddArticle yddArticle);


    /**
     * 按标题选择计数
     *
     * @param title 标题
     * @return {@link Integer}
     */
    @Select("select count(*) from ydd_article where title=#{title}")
    Integer selectCountByTitle(String title);

    /**
     * 选择按标题计数而不是id
     *
     * @param title 标题
     * @param id    id
     * @return {@link Integer}
     */
    @Select("select count(*) from ydd_article where title=#{title} and id!=#{id}")
    Integer selectCountByTitleNotId(String title, Integer id);

    /**
     * 选择按时间计数
     *
     * @param dayStartTime 日开始时间
     * @param endTime      结束时间
     * @return {@link Integer}
     */
    Integer selectCountByTime(Long StartTime, Long endTime);

    /**
     * 选择热门文章
     *
     * @return {@link List}<{@link ArticleHot}>
     */
    List<ArticleHot> selectHotArticles();

    /**
     * 选择推荐文章
     *
     * @return {@link List}<{@link ArticleHot}>
     */
    List<ArticleHot> selectRecommendArticles();

    /**
     * 按cate id选择
     *
     * @param cateid cateid
     * @return {@link List}<{@link YddArticleRecommend}>
     */
    List<YddArticleRecommend> selectByCateId(Integer cateid);

    /**
     * 所有文章显示部分
     *
     * @return {@link List}<{@link YddArticleShowPart}>
     */
    List<YddArticleShowPart> allArticleShowPart();

    /**
     * 查询所有文章
     *
     * @return {@link List}<{@link YddArticle}>
     */
    List<YddArticle> queryAllArticle();
}
